package 双指针.删除有序数组中的重复项80;

import utils.Utils;

public class Solution {
    public static int removeDuplicates(int[] nums) {
        int n = nums.length;
        if (n <= 2) {
            return n;
        }
        int slow = 2, fast = 2;
        while (fast < n) {
            // 重点在于不在乎后面是啥
            if (nums[slow - 2] != nums[fast]) {
                nums[slow] = nums[fast];
                ++slow;
            }
            ++fast;
        }

        Utils.printIntArr(nums);
        return slow;

    }

    public static void main(String[] args) {
        int[] nums = {0,0,1,1,1,1,2,3,3};
        Utils.printInt(removeDuplicates(nums));
    }
}
